package com.fxu.tpl.enums;

import com.fxu.framework.core.enums.BaseEnum;
import lombok.AllArgsConstructor;

/***
 * <p>yuye</p>
 * 字段表：[column]的数据实体枚举类
 * @author fangxu
 * @version 2022-03-10
 ***/
@AllArgsConstructor
public enum ColumnTypeEnum implements BaseEnum<Integer, String> {
    String(1, "String"),
    Boolean(2, "Boolean"),
    Integer(3, "Integer"),
    Long(4, "Long"),
    Float(5, "Float"),
    Double(6, "Double"),
    Decimal(7, "Decimal"),
    Date(8, "Date"),
    DateTime(11, "Date"),
    Text(9, "Text"),
    Blob(10, "Blob"),
    ;

    Integer code;
    String desc;

    @Override
    public Integer code() {
        return code;
    }

    @Override
    public String desc() {
        return desc;
    }

    public static String desc(Integer code) {
        ColumnTypeEnum ret = find(code);
        return ret == null ? null : ret.desc;
    }

    public static ColumnTypeEnum find(Integer code) {
        return code == null ? null : BaseEnum.findOne(values(), v -> v.code.equals(code));
    }
}